<?php

class InfoController extends BaseController
{
	
	public $leftmenusTitle = '最近通知';
	
	
	protected function beforeAction($action)
    {
    	Yii::app()->clientScript->registerScriptFile(Yii::app()->createUrl('js/depart'));
    	$notices=Notice::model()->recently()->findAll();
    	$this->leftmenus = array();
    	foreach ($notices as $key => $value) {
    		# code...
    		$this->leftmenus[] = array('href'=>$this->createUrl('notice/index',array('no'=>$value->id)),'menutext'=>'['.substr($value->create_time,0,10).'] '.$value->title,'isValid'=>true,'isNew'=>((strtotime("now")-strtotime(substr($value->create_time,0,10)))/24/60/60<3),);
    	}
    	
        return true;
    } 
	/**
	 * 子功能首页
	 */
	public function actionIndex()
	{

	}
	
	public function actionChange()
	{
		$model = User::model()->findByStaffId(Yii::app()->user->id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		if(isset($_POST['User']))
		{
			$model->attributes=$_POST['User'];
			if($model->validate())
			{
				$model->save();
				Yii::app()->session['currenUser'] = $model;
				Yii::app()->user->setFlash('success','资料修改成功!');
			}
		}
		$this->render('change',array(
			'model'=>$model,
		  ));
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}